// https://umijs.org/config/
import { defineConfig } from 'umi';
import defaultSettings from './defaultSettings';
import proxy from './proxy';
const { REACT_APP_ENV } = process.env;

export default defineConfig({
  hash: true,
  antd: {},
  dva: {
    hmr: true,
  },
  locale: {
    // default zh-CN
    default: 'zh-CN',
    // default true, when it is true, will use `navigator.language` overwrite default
    antd: true,
    baseNavigator: true,
  },
  dynamicImport: {
    loading: '@/components/PageLoading/index',
  },
  targets: {
    ie: 11,
  },
  // umi routes: https://umijs.org/docs/routing
  routes: [
    {
      path: '/user',
      component: '../layouts/UserLayout',
      routes: [
        {
          name: 'login',
          path: '/user/login',
          component: './user/login',
        },
      ],
    },
    {
      path: '/web',
      routes: [
        {
          name: 'web',
          path: '/web',
          component: './web',
        },
        {
          name: 'detail',
          path: '/web/detail',
          component: './web/detail',
        },
        {
          name: 'web',
          path: '/web/:id',
          component: './web',
        },
      ],
    },
    {
      path: '/',
      component: '../layouts/SecurityLayout',
      routes: [
        {
          path: '/',
          component: '../layouts/BasicLayout',
          authority: ['admin', 'user'],
          routes: [
            {
              path: '/',
              redirect: '/welcome',
            },
            {
              path: '/welcome',
              name: 'welcome',
              icon: 'DashboardOutlined',
              component: './Welcome',
            },            
            {
              path: '/ContactBook',
              name: 'ContactBook',
              icon: 'ContactsOutlined',
              component: './ContactBook',
            },
            {
              name: 'dashboard',
              icon: 'dashboard',
              path: '/dashboard',
              component: './Dashboard',
              authority: ['adminx'],
            },
            {
              path: '/manage',
              name: 'manage',
              icon: 'SettingOutlined',
              authority: ['admin'],
              routes: [
                {
                  path: '/manage/department',
                  name: 'department',
                  component: './manage/department',
                },
                {
                  path: '/manage/users',
                  name: 'users',
                  component: './manage/users',
                },
                {
                  path: '/manage/authority',
                  name: 'authority',
                  component: './manage/authority',
                },
                {
                  path: '/manage/modules',
                  name: 'modules',
                  component: './manage/modules',
                },
                {
                  path: '/manage/sysconfig',
                  name: 'sysconfig',
                  component: './manage/sysconfig',
                },
              ],
            },
            {
              path: '/admin',
              name: 'admin',
              icon: 'AppstoreOutlined',
              authority: ['admin'],
              routes: [
                {
                  path: '/admin/content',
                  name: 'content',
                  component: './admin/content',
                },
                {
                  path: '/admin/contEdit',
                  name: 'contEdit',
                  component: './admin/contEdit',
                },
                {
                  path: '/admin/myModule',
                  name: 'mymodule',
                  component: './admin/myModule',
                },
              ]
            },
            {
              path: '/saleorder',
              name: 'saleorder',
              icon: 'AppstoreOutlined',
              authority: ['admin'],
              routes: [
                {
                  path: '/saleorder/orderEntry',
                  name: 'orderEntry',
                  component: './saleorder/orderEntry',
                },
                {
                  path: '/saleorder/customer',
                  name: 'customer',
                  component: './saleorder/customer',
                },
                {
                  path: '/saleorder/report',
                  name: 'report',
                  component: './saleorder/report',
                },
              ]
            },
            {
              path: '/part',
              name: 'part',
              icon: 'AppstoreOutlined',
              authority: ['admin'],
              routes: [
                {
                  path: '/part/partEntry',
                  name: 'partEntry',
                  component: './part/partEntry',
                },
                {
                  path: '/part/shipEntry',
                  name: 'shipEntry',
                  component: './part/shipEntry',
                },
                {
                  path: '/part/rcvEntry',
                  name: 'rcvEntry',
                  component: './part/rcvEntry',
                },
                {
                  path: '/part/InspEntry',
                  name: 'InspEntry',
                  component: './part/InspEntry',
                },
                {
                  path: '/part/DMREntry',
                  name: 'DMREntry',
                  component: './part/DMREntry',
                },
              ]
            },
            {
              path: '/purchase',
              name: 'purchase',
              icon: 'AppstoreOutlined',
              authority: ['admin'],
              routes: [
                {
                  path: '/purchase/poSugg',
                  name: 'poSugg',
                  component: './purchase/poSugg',
                },
                {
                  path: '/purchase/poEntry',
                  name: 'poEntry',
                  component: './purchase/poEntry',
                },
                {
                  path: '/purchase/vendor',
                  name: 'vendor',
                  component: './purchase/vendor',
                },
                {
                  path: '/purchase/vendorPrice',
                  name: 'vendorPrice',
                  component: './purchase/vendorPrice',
                },
              ]
            },
            {
              path: '/manufacture',
              name: 'manufacture',
              icon: 'AppstoreOutlined',
              authority: ['admin'],
              routes: [
                {
                  path: '/manufacture/jobEntry',
                  name: 'jobEntry',
                  component: './manufacture/jobEntry',
                },
                {
                  path: '/manufacture/resourceGroup',
                  name: 'resourceGroup',
                  component: './manufacture/resourceGroup',
                },
                {
                  path: '/manufacture/opMaster',
                  name: 'opMaster',
                  component: './manufacture/opMaster',
                },
                {
                  path: '/manufacture/bomDesign',
                  name: 'bomDesign',
                  component: './manufacture/bomDesign',
                },
              ]
            },
            {
              name: 'list.table-list',
              icon: 'table',
              path: '/list',
              component: './ListTableList',
            },            
            {
              component: './404',
            },
          ],
        },
        {
          component: './404',
        },
      ],
    },
    {
      component: './404',
    },
  ],
  // Theme for antd: https://ant.design/docs/react/customize-theme-cn
  theme: {
    // ...darkTheme,
    'primary-color': defaultSettings.primaryColor,
  },
  // @ts-ignore
  title: false,
  ignoreMomentLocale: true,
  proxy: proxy[REACT_APP_ENV || 'dev'],
  manifest: {
    basePath: '/',
  },
});
